<?//error_reporting(E_ALL);$zdir = 1;include("../includes/functions.php");$masterMail = MASTER_MAIL;$masterFrom = MASTER_FROM;
if ($_POST[upload] == 1) {	$fileProgramID = $_POST[program];	$fileNotes     = fieldToDB($_POST[fileNotes]);
	$error = 0;	$upload = 1;
	$someFile     = $_FILES['fileUpload']['tmp_name'];	$someFileName = $_FILES['fileUpload']['name'];	$someFileType = $_FILES['fileUpload']['type'];	$someFileSize = $_FILES['fileUpload']['size'];	// Check for acceptable filetype	for($a=0;$a<=(count($arrayAcceptFileTypes)-1);$a++) {		if ($someFileType == $arrayAcceptFileTypes[$a]) { 			$success = 1; 			$fileType = $arrayAcceptFileTypesShort[$a];		}	}	if ($success != 1) {		$error = 1;		$message = 'Sorry! This form only accepts Excel and Word files for upload.';					}
	// Check for empty program field	if ( ($fileProgramID == 'Select Program...') || empty($fileProgramID) ) {		$error = 1;		$message = 'Please select your program.';	}
	// Check for empty file field	if (empty($someFile)) {		$error = 1;		$message = 'Please select a file to upload.';	}
	if ($error != 1) {		// Replace original filename with program name		$sql1 = "SELECT ProgramName from casa_programs WHERE PID = '$fileProgramID'";		$result1 = mysql_db_query($dbname,$sql1);		$row1 = mysql_fetch_assoc($result1);		$progName = stripslashes($row1[ProgramName]);				// Get original file extension		$fileNameArray = explode('.',$someFileName);		// Extension will be the last chunk		$fileExt = $fileNameArray[count($fileNameArray)-1];
		// Let's keep the first chunk for our filename
		$fileNamePiece = $fileNameArray[0];
		$newFilename = cleanString($progName.'_'.$fileNamePiece).'_'.random_string(5).'.'.$fileExt;		$filePath = $rootDir.$newFilename;		
		if(move_uploaded_file($someFile, $filePath)){			// If we uploaded an image, create thumbnail view			/*			if ($image == 1) {				resize_image($filePath,'',100,'thumb',0,0,$someFileType);			}			*/								// Add file to database			$sql = "INSERT into casa_uploads (					PID,					FileName,					FileNotes,					FileType,					DateUpload					) values (					'$fileProgramID',					'$newFilename',					'$fileNotes',					'$fileType',					'".date('Y-m-d')."'					)";			$result = mysql_db_query($dbname,$sql);					} else {			$error = 1;		}			}	} else {	$error = 0;	$upload = 0;	}?>
<html><head><script language="javascript">function uploadComplete(upload,error) {	if (upload == 1) {		var progressDiv = window.parent.document.getElementById('uploadStatus');		var statusDiv   = document.getElementById('uploadStatus2');		if (error == 1) {			progressDiv.innerHTML = '';			statusDiv.innerHTML   = '<img src="../images/iconError.gif"> <?=$errorMessage; ?>';		} else {			progressDiv.innerHTML = '';			statusDiv.innerHTML   = '<img src="../images/iconStatusComplete.gif"> <b>Your Upload Was Successful!</b>';		}	}}function uploadFile(){	var par = window.parent.document;	var iframe = par.getElementById('fileFrame');	var form   = document.getElementById('iform');				var progressDiv = par.getElementById('uploadStatus');	progressDiv.innerHTML = '<img src="../images/ajaxAnimBar.gif">';
	// send	form.submit();	}</script><head><link rel="STYLESHEET" media="screen" href="<?=$pre; ?>css/<?=$styleSheet; ?>" type="text/css" />	<style>body {	background: #EBF4FD;	font-size: 68.75%; /* Resets 1em to 11px */	font-family: Verdana, Arial;	line-height: 17px;}td,p,table,tr,input,select,textarea {	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 1em;}</style><SCRIPT src="<?=$pre; ?>js/jsCommon.js" type="text/javascript"></SCRIPT><SCRIPT src="<?=$pre; ?>js/protaculous/prototype.js" type="text/javascript"></SCRIPT><script language="JavaScript" type="text/javascript">function jScriptInit() {	//initToolTips();}</script><?if ( ($error != 1) && ($_POST[upload] == 1) ) {	// Send email notification to everyone in $arrayUploadNotify	for($a=0;$a<=(count($arrayUploadNotify)-1);$a++) {
		//echo 'Mail sent to: '.$arrayUploadNotify[$a].'<br>';		$recipient = $arrayUploadNotify[$a];		if (empty($fileNotes)) { $fileNotes = '(No notes submitted)'; }		$subject  = 'File Upload from '.$progName;		$message  = $progName.' has just uploaded the following file: '.$filename.Chr(10).Chr(10);		$message .= '---- NOTES --------------------------------------------------------'.Chr(10);		$message .= $fileNotes.Chr(10).Chr(10);
		$message .= '-------------------------------------------------------------------'.Chr(10);
		$message .= 'To view this file, log on to the CASA3G administration area at:'.Chr(10);
		$message .= 'http://www.casa3g.org/admin'.Chr(10);
		$message .= 'Click on Site Maintenance and then click the Assessment File Uploads tab.';
				@mailNew($masterFrom, $masterMail, $recipient, $subject, $message);					}}		?></head><body onload="jScriptInit(); uploadComplete(<?=$upload; ?>,<?=$error; ?>);">	<form name="iform" id="iform" method="post" enctype="multipart/form-data">	<input type="hidden" name="upload" value="1">
	<div style="margin-top: -8px;">		<? //echo '<br>File Type: '.$someFileType; ?>		<?		if ($error == 1) {			echo '<span style="color: red; font-size: 1.2em;"><b><u>Oops!</u> '.$message.'</b></span>';		} else {			echo '<b>NOTE:</b> MS Excel and Word files only please.';		}		?>		<p><label><b>Select your program</b></label><br />			<select name="program" id="program" style="width: 300px;" size="1">			<option>Select Program...</option>			<option></option>			<? 			$sql = "SELECT * from casa_programs ORDER BY ProgramName";			$result = mysql_db_query($dbname,$sql);			while ($value = mysql_fetch_assoc($result)) {				$progID   = $value[PID];				$progName = stripslashes($value[ProgramName]);				echo '<option value="'.$progID.'"';				if ($fileProgramID == $progID) {					echo ' selected ';				}				echo '>'.$progName.'</option>'."\n";			}			?>			</select>		</p>			<p><label class="required"><b>Select your file</b></label><br />		<input type="file" id="fileUpload" name="fileUpload" size="42" style="width: 275px;" /></p>	
		<p><label><b>Notes</b></label><br />		<textarea id="fileNotes" name="fileNotes" style="width: 300px; height: 50px;"></textarea></p>		<div style="margin-top: -8px;">			<div style="margin-right: 20px; float: left;">				<input type="image" src="<?=$pre; ?>images/buttonUploadSmall.gif" onClick="uploadFile();" alt="Upload File" style="border: none;">			</div>			<div style="float: left;" id="uploadStatus2"></div>			<div style="clear: left;"></div>		</div>	
	</div>		</form></body>	</html>